<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head th:replace="dashboard/header :: header"></head>
<body>
	<div layout:fragment="content">
		<div class="container-fluid content-main">
			<div class="animated fadeIn">
				<div class="row">
					<!-- /.col-->
					<div class="col-sm-12">
						<div class="card">
							<div class="card-body">
					
								<form class="form-horizontal" id="addForm">
									
									<input type="hidden" name="formToken" th:value="${session.formToken}" />
								
									<div class="form-group row">
										<label class="col-md-3 col-form-label" for="text-input">所属应用</label>
										<div class="col-md-9">
											<input class="form-control" id="text-input" type="text"  th:value="${bean.applicationId}" onclick="showApplication()" name="applicationIdLabel" readonly="readonly" style="cursor: pointer" placeholder="所属应用">
											<input type="hidden" th:value="${bean.applicationId}" name="applicationId"  />
										</div>
									</div>
									<div class="form-group row">
										<label class="col-md-3 col-form-label" for="email-input">代码类型</label>
										<div class="col-md-9">
											<input class="form-control" id="email-input" type="text" name="codeValue" placeholder="代码类型">
										</div>
									</div>
									
									<div class="form-group row">
										<label class="col-md-3 col-form-label" for="email-input">代码值 </label>
										<div class="col-md-9">
											<input class="form-control" id="email-input" type="text" name="codeValue" placeholder="代码值">
										</div>
									</div>
									<div class="form-group row">
										<label class="col-md-3 col-form-label" for="email-input">使用状态</label>
										<div class="col-md-9">
											<self:dictionary type="common_status" name="hasStatus" />	
										</div>
									</div>
								</form>

							</div>

							<div class="card-footer">
								<button class="btn btn-primary" style="float: right" onclick="save()" type="button">保存</button>
							</div>

						</div>
					</div>
					<!-- /.col-->
				</div>
			</div>
		</div>

	</div>
	
	<script th:src="@{/asserts/vendors/jquery/js/jquery.min.js}"></script>
	<script th:src="@{/asserts/vendors/jquery.form/jquery.form.min.js}"></script>
	
	<script th:src="@{/asserts/vendors/layer/layer.js}"></script>
	<script th:src="@{/asserts/js/global.js}"></script>
	
	<script type="text/javascript">
	
		// 保存操作
		function save(){
			$("#addForm").ajaxSubmit({
				url: ctx+"boot/platform/dictionary/save",
				type: "POST" ,
				success: function (data) {
					if(data.code == 200){
						layer.msg("操作成功!") ; 
					}else{
						layer.alert(data.message) ; 
					}
				}
			});	
		}	
		
		function showApplication(){
			var index = layer.open({
				type : 2,
				title : false , //'菜单管理',
				closeBtn:0 ,
				shadeClose : true,
				shade : 0.8,
				area : [ '100%', '100%' ],
				content : ctx+'boot/platform/application/select' , 
				btn: ['确认', '取消'] , 
				yes: function(index, layero){
					console.log("index = " + index + " layero = " + layero) ; 
					var selectResourceParentNode = $(layero).find("iframe")[0].contentWindow.document.getElementById("selectResourceParentNode")
					
					var resourceName = $(selectResourceParentNode).attr("data-applicationName") ; 	
					var id = $(selectResourceParentNode).attr("data-id") ; 	
					
					console.log("applicationId = " + id + " , applicationIdLabel = " + resourceName) ;
					
					$("input[name=applicationIdLabel]").val(resourceName) ; 
					$("input[name=applicationId]").val(id) ; 
					
					layer.close(index) ; 
			 	}
			});		
		}

	</script>
	
</body>
</html>
